package 强化训练;

import java.util.Scanner;

public class day19汽水瓶 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            int n = sc.nextInt();
            if(n == 0) return;
            help(n,0);
        }
    }
    public static void help(int n,int res){
        int a = n / 3;
        int b = n % 3;
        if(a == 0){
            if(b >= 2){
                System.out.println(res + 1);
                return;
            }else{
                System.out.println(res);
                return;
            }

        }
        res += a;
        help(a+b,res);

    }
}
